
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
function resolve(dir) {
  return path.join(__dirname, dir);
}
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:5000', // 设置代理目标
        changeOrigin: true, // 是否改变请求源地址
        rewrite: (path) => path.replace(/^\/api/, '') // 将 /api 替换为空字符串
      }
    }
  },
  resolve: {
    alias: {
      '@': resolve("src")
      // '@': path.resolve(__dirname, '/src') // 根据你的项目结构进行修改
      // '@': '/src',
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "@/assets/styles/variables.scss";
                        @import "@/assets/styles/common.scss";` // 根据你的样式文件路径进行修改
        // prependData: `@import "@/assets/styles/variables.scss";
        //              @import "@/assets/styles/common.scss";`
      }
    }
  }
})
